import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import legacy from '@vitejs/plugin-legacy'

// https://vite.dev/config/
import path from 'path'

export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [VantResolver()],
    }),
    legacy({
      targets: ['defaults', 'not IE 11']
    })
  ],
  optimizeDeps: {
    include: ['echarts']
  },
  server: {
    proxy: {
      "/api": {
        // target: "https://www.jumaiym.com/api/",
          target: "http://154.38.116.108:8090/api/",
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/api/, "")
      },
      // "/v1": {
      //   target: "https://api.jumaiym.com/v1/",
      //   changeOrigin: true,
      //   rewrite: (p) => p.replace(/^\/v1/, "")
      // },
      // "/market": {
      //   target: "https://api.huobi.pro/market/",
      //   changeOrigin: true,
      //   rewrite: (p) => p.replace(/^\/market/, "")
      // }
    }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      'pinia-plugin-persistedstate': path.resolve(__dirname, 'node_modules/pinia-plugin-persistedstate/dist')
    }
  }
})
